<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript">
		function setCookie() {
		var Then = new Date();　　
	　	Then.setTime(Then.getTime() + 1*3600000 ); //小时　　
		document.cookie = "ddhname="+encodeURI("丁大海")+";expires="+Then.toGMTString()+";path=/";
	}
	setCookie();
	function getCookie(cookie_name){
		var allcookies = document.cookie;
		var cookie_pos = allcookies.indexOf(cookie_name);
		// 如果找到了索引，就代表cookie存在，
		// 反之，就说明不存在。
		if (cookie_pos != -1) {
			// 把cookie_pos放在值的开始，只要给值加1即可。
			cookie_pos += cookie_name.length + 1;
			var cookie_end = allcookies.indexOf(";", cookie_pos);
			
			if (cookie_end == -1) {
				cookie_end = allcookies.length;
			}
			
			var value = allcookies.substring(cookie_pos, cookie_end);
		}
		return decodeURI(value);
	}
	</script>
  </head>
  
  <body>
    cookie.setMaxAge(-1);
    <a href="javascript:void(0)" onclick="alert(getCookie('ddhname'));">getcookie</a>
    
    <a href="refer.do?method=refer&asdf=cccsdfasdf">Referer</a>
  </body>
</html>
